package cn.jiyun.controller;


import cn.jiyun.common.config.Result;
import cn.jiyun.entity.XmAuditcouriers;
import cn.jiyun.service.IXmAuditcouriersService;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;

import org.springframework.web.bind.annotation.RestController;

import java.time.LocalDateTime;

/**
 * <p>
 *  前端控制器
 * </p>
 *
 * @author author
 * @since 2024-11-28
 */
@RestController
@RequestMapping("/xm-client/xm-auditcouriers")
public class XmAuditcouriersController {

    @Autowired
    private IXmAuditcouriersService xmAuditcouriersService;


//    查询在审核的骑手
    @RequestMapping("findAll")
    public Result findAll(Integer current, Integer pageSize, @RequestBody XmAuditcouriers xmAuditcouriers){
        Page<XmAuditcouriers> xmAuditcouriersPage=xmAuditcouriersService.findAll(current,pageSize,xmAuditcouriers);
        return Result.ok(xmAuditcouriersPage);
    }


//    根据id查询审核信息

    @RequestMapping("findById")
    public Result findById(Integer id){
        XmAuditcouriers xmAuditcouriers=xmAuditcouriersService.getById(id);
        return Result.ok(xmAuditcouriers);
    }


//    修改审核状态

    @RequestMapping("updateStatus")
    public Result updateStatus(@RequestBody XmAuditcouriers xmAuditcouriers){
        xmAuditcouriersService.updateStatus(xmAuditcouriers);
        return  Result.ok();
    }


//    添加配送员的审核信息
    @RequestMapping("add")
    public Result add(@RequestBody XmAuditcouriers xmAuditcouriers){
        xmAuditcouriers.setCommitTime(LocalDateTime.now());
        xmAuditcouriers.setType(1);
        xmAuditcouriersService.save(xmAuditcouriers);
        return Result.ok();
    }

}
